﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Tao.OpenGl;
using Tao.Platform.Windows;
using System.Diagnostics;

namespace TaoGL_UserControl
{
    class PianoKeyLong:Tex2DUV
    {
        string[] ImgTable =
        {
            "type_01_specialbutton_001.tga","type_01_specialbutton_002.tga","type_01_specialbutton_003.tga","type_01_specialbutton_004.tga","type_01_specialbutton_005.tga",
            "type_01_specialbutton_006.tga","type_01_specialbutton_007.tga","type_01_specialbutton_008.tga","type_01_specialbutton_009.tga","type_01_specialbutton_010.tga",
            "type_01_specialbutton_011.tga","type_01_specialbutton_012.tga","type_01_specialbutton_013.tga","type_01_specialbutton_014.tga","type_01_specialbutton_015.tga",
            "type_01_specialbutton_016.tga","type_01_specialbutton_017.tga","type_01_specialbutton_018.tga","type_01_specialbutton_019.tga","type_01_specialbutton_020.tga",
            "type_01_specialbutton_021.tga","type_01_specialbutton_022.tga","type_01_specialbutton_023.tga","type_01_specialbutton_024.tga","type_01_specialbutton_025.tga",
            "type_01_specialbutton_026.tga","type_01_specialbutton_027.tga","type_01_specialbutton_028.tga","type_01_specialbutton_029.tga","type_01_specialbutton_030.tga",
            "type_01_specialbutton_031.tga","type_01_specialbutton_032.tga","type_01_specialbutton_033.tga","type_01_specialbutton_034.tga","type_01_specialbutton_035.tga",
            "type_01_specialbutton_036.tga","type_01_specialbutton_037.tga","type_01_specialbutton_038.tga","type_01_specialbutton_039.tga","type_01_specialbutton_040.tga",
            "type_01_specialbutton_041.tga","type_01_specialbutton_042.tga","type_01_specialbutton_043.tga","type_01_specialbutton_044.tga","type_01_specialbutton_045.tga",
            "type_01_specialbutton_046.tga","type_01_specialbutton_047.tga","type_01_specialbutton_048.tga","type_01_specialbutton_049.tga","type_01_specialbutton_050.tga",
            "type_01_specialbutton_051.tga","type_01_specialbutton_052.tga","type_01_specialbutton_053.tga","type_01_specialbutton_054.tga","type_01_specialbutton_055.tga",
            "type_01_specialbutton_056.tga","type_01_specialbutton_057.tga","type_01_specialbutton_058.tga","type_01_specialbutton_059.tga","type_01_specialbutton_060.tga",

            "type_01_specialbutton_100.tga", "type_01_specialbutton_101.tga","type_01_specialbutton_102.tga","type_01_specialbutton_103.tga","type_01_specialbutton_104.tga",
            "type_01_specialbutton_105.tga", "type_01_specialbutton_106.tga","type_01_specialbutton_107.tga","type_01_specialbutton_108.tga","type_01_specialbutton_109.tga",
            "type_01_specialbutton_110.tga", "type_01_specialbutton_111.tga","type_01_specialbutton_112.tga","type_01_specialbutton_113.tga","type_01_specialbutton_114.tga",
            "type_01_specialbutton_115.tga", "type_01_specialbutton_116.tga","type_01_specialbutton_117.tga","type_01_specialbutton_118.tga","type_01_specialbutton_119.tga",
            "type_01_specialbutton_120.tga", "type_01_specialbutton_121.tga","type_01_specialbutton_122.tga","type_01_specialbutton_123.tga","type_01_specialbutton_124.tga",
            "type_01_specialbutton_125.tga", "type_01_specialbutton_126.tga","type_01_specialbutton_127.tga","type_01_specialbutton_128.tga","type_01_specialbutton_129.tga",
            "type_01_specialbutton_130.tga", "type_01_specialbutton_131.tga","type_01_specialbutton_132.tga","type_01_specialbutton_133.tga","type_01_specialbutton_134.tga",
            "type_01_specialbutton_135.tga", "type_01_specialbutton_136.tga","type_01_specialbutton_137.tga","type_01_specialbutton_138.tga","type_01_specialbutton_139.tga",
            "type_01_specialbutton_140.tga", "type_01_specialbutton_141.tga","type_01_specialbutton_142.tga","type_01_specialbutton_143.tga","type_01_specialbutton_144.tga",
            "type_01_specialbutton_145.tga", "type_01_specialbutton_146.tga","type_01_specialbutton_147.tga","type_01_specialbutton_148.tga","type_01_specialbutton_149.tga",
            "type_01_specialbutton_150.tga", "type_01_specialbutton_151.tga","type_01_specialbutton_152.tga","type_01_specialbutton_153.tga","type_01_specialbutton_154.tga",
            "type_01_specialbutton_155.tga", "type_01_specialbutton_156.tga","type_01_specialbutton_157.tga","type_01_specialbutton_158.tga","type_01_specialbutton_159.tga",
        };

        //======================================================================
        public PianoKeyLong()
        {
            foreach (string fp in ImgTable)
                TexMgr.LoadTextureEx(PathMgr.Img + fp);

            ChangeImage(0);
            Rectangle rect = TexMgr.GetTextureInfo(ImgTable[0]).rectange;
            SetSize(rect.Width, rect.Height);
        }
        //======================================================================
        public void ChangeImage(int num)
        {
            if (num < ImgTable.Length && num >= 0)
                TextureIndex = TexMgr.GetTextureInfo(ImgTable[num]).Index;
            else
                Debug.WriteLine("PianoKeyLong Chage Image Num Error:" + num);
        }
        //======================================================================
        public void DispRate(float Per)
        {
            int Num = 0;
            if (Per >= 1)
            {
                Per %= 1.0f;
                Num = (int)((float)((ImgTable.Length / 2) - 1) * Per);
                Num += 60;
            }
            else if (Per >= 0)
            {
                Num = (int)((float)((ImgTable.Length / 2) - 1) * Per);
            }
            ChangeImage(Num);
        }
    




    }



}
